import request from '@/config/axios'

// 商品采购订单 VO
export interface PurchaseOrderVO {
  id: number // 主键id
  productId: string // 商品id
  purchasingChannels: string // 采购渠道
  channelOrder: string // 渠道订单号
  onlineOrder: string // 线上订单号
  supplier: string // 供应商
  storeId: number // 仓库id
  storeName: string // 仓库名称
  trackingNumber: string // 物流单号
  purchaseName: string // 采购人员
  purchaseDate: Date // 采购时间
  remark: string // 备注
  deptId: number // 部门id
  deptName: string // 部门名称
}

// 商品采购订单 API
export const PurchaseOrderApi = {
  // 查询商品采购订单分页
  getPurchaseOrderPage: async (params: any) => {
    return await request.get({ url: `/admin-api/product/purchase-order/page`, params })
  },

  // 查询商品采购订单详情
  getPurchaseOrder: async (id: number) => {
    return await request.get({ url: `/admin-api/product/purchase-order/get?id=` + id })
  },

  // 查询商品采购订单详情
  getPurchaseLinkByProductId: async (productIds: string) => {
    return await request.get({ url: `/admin-api/product/purchase/getPurchaseLinkList?productIds=` + productIds })
  },

  // 新增商品采购订单
  createPurchaseOrder: async (data: PurchaseOrderVO) => {
    return await request.post({ url: `/admin-api/product/purchase-order/create`, data })
  },

  // 修改商品采购订单
  updatePurchaseOrder: async (data: PurchaseOrderVO) => {
    return await request.put({ url: `/admin-api/product/purchase-order/update`, data })
  },

  // 删除商品采购订单
  deletePurchaseOrder: async (id: number) => {
    return await request.delete({ url: `/admin-api/product/purchase-order/delete?id=` + id })
  },

  // 导出商品采购订单 Excel
  exportPurchaseOrder: async (params) => {
    return await request.download({ url: `/admin-api/product/purchase-order/export-excel`, params })
  },

  inventoryIn:async(params:{
    sku:string;
    purchaseOrderId:string
  })=>{
    return await request.put({ url: `/admin-api/product/purchase-order-detail/updateAudit`,params: params })
  }
}
